<template>
	<view class="centerBox">
		<nav-bar home :bgColor="['#CCCCCC','#CCCCCC']" fontColor="#FFFFFF" title="养殖农户"></nav-bar>
		<v-tabs v-model="activeTab" @change="changeTab" :scroll="false" :bold="true" :tabs="tabs1"
			field="name"></v-tabs>
		<view class="content">
			
				<button class="add-btn" type="primary"   @click="handleAdd">添加农户/养殖场</button>
			
			<view class="supplierList" v-for="item in dataList"  @click="jiuxindai(item)">
				<view style="width: 100%;height: 170rpx;">
					<view style="display: flex;width: 95%;margin: 0 auto;height: 100rpx;">
						<view style="font-size: 35rpx;line-height: 100rpx;">农户姓名:{{item.supplierName}} 乡镇:{{item.district}}</view>
						<!-- <view class="tag">{{item.productType}}</view> -->
					</view>
					<view style="color: gray;width: 95%;margin: 0 auto;">养殖地址：{{item.address}} </view>
						<view style="color: gray;width: 95%;margin: 0 auto;">电话：{{item.contactPhone}} </view> 
					<view style="display: flex;border-bottom: 1px solid #e3e3e3;">
					
					</view>
					
				</view></view>
	</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabs1: [{
						name: '农户',
						value: '农户'
					},
					{
						name: '养殖场',
						value: '养殖场'
					}
				],
				dataList: [],
				activeTab: 0,
				askList: [{
						title: '还款方式',
						sub: '随借随还'
					},
					{
						title: '融资主体',
						sub: '企业'
					},
					{
						title: '产品特点',
						sub: '线上审批，通过率高'
					}
				],
				title: '',
				proveStatus: false,
				form: {}
			}
		},
		onLoad() {
			this.getUserInfo();
			this.findSupplierList('农户');
			//this.statusSearch();
		},
		methods: {
			changeTab(e) {
				this.activeTab = e
			
				
				if (e == 0) {
					const typeList = '农户'
					this.findSupplierList(typeList)
				} else if (e == 1) {
					const typeList = '养殖场'
					this.findSupplierList(typeList)
				} 
			},
			handleAdd() {
			  uni.navigateTo({
			    url: `/pages/resource/addSupplier`
			  });
			},
			findSupplierList(typelist) {
			
				let opt = {
					url: 'basic/supplier/search',
					method: 'POST'
				};
				
				let params = {
					customerNo: uni.getStorageSync('userInfo').customerId,
				
					supplierType: typelist
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					let rangeList = res.data.data
					for (let i in rangeList) {
					//	rangeList[i].finLoanProduct.creditLineUpto = rangeList[i].finLoanProduct.creditLineUpto /
					//		10000
					}
					this.dataList = rangeList
					console.log(this.dataList)
				})
			},
			jiuxindai(e){
				let limitData = JSON.stringify(e)
				//alert(limitData);
				uni.navigateTo({
					url:'/pages/resource/supplierView?id=' +limitData
				})
			},
			statusSearch() {
				let opt = {
					url: 'baoli/finCustomerCreditApplication/search',
					method: 'POST'
				};
				let params = {
					customerNo: uni.getStorageSync('userInfo').customerId,
					proveStatusList: ['proved']
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					if (res.data.data != '') {
						this.proveStatus = true
					}
					else{
						uni.showToast({
							title:'暂无数据',
							icon: 'none'
						})
						this.proveStatus = false
					}
				})
			},
			getUserInfo() {
				let opt = {
					url: 'basic/customer/getMyCustInfor',
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					if (res.data.code == 200) {
						this.form = res.data.data
					}
				})
			},
			launch() {
				let formData = JSON.stringify(this.form)
				uni.navigateTo({
					url: '/pages/product/launch-product?id=' + formData
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f4f4f4;
	}

	.flex {
		display: flex;
	}

	.tag {
		color: dodgerblue;
		background: #FFFFFF;
		width: 120rpx;
		height: 50rpx;
		text-align: center;
		border-radius: 25px;
		font-size: 25rpx;
		line-height: 50rpx;
		background: #b5e3ff;
		position: absolute;
		right: 5%;
		margin-top: 30rpx;

	}

	.tag1 {
		color: #00d900;
		background: #FFFFFF;
		width: 120rpx;
		height: 50rpx;
		text-align: center;
		border-radius: 25px;
		font-size: 25rpx;
		line-height: 50rpx;
		margin: 20rpx 10rpx;
	}

	.tag2 {
		color: #e8d609;
		background: #FFFFFF;
		width: 120rpx;
		height: 50rpx;
		text-align: center;
		border-radius: 25px;
		font-size: 25rpx;
		line-height: 50rpx;
		margin: 20rpx 10rpx;
	}

	.topBgColor {
		width: 100%;
		height: 400rpx;
		background-image: linear-gradient(to right, #495aff 0%, #0acffe 100%);
	}

	.topTitle {
		display: flex;
		height: 100rpx;
		padding: 20rpx;

		span {
			font-size: 40rpx;
			color: #FFFFFF;
			font-weight: bold;
			line-height: 100rpx;
			margin-left: 20rpx;
		}

		image {
			height: 40rpx;
			width: 40rpx;

		}

		.jiantou {
			line-height: 120rpx;
		}

	}

	.addressBox {
		width: 95%;
		margin: 0 auto;
		background: #FFFFFF;
		border-radius: 15rpx;
		// margin-top: 100rpx;
		position: absolute;
		height: 350rpx;
		top: 14%;
		left: 2.5%;
		margin-top: 60rpx;
		text-align: center;
	}

	.centerBox {
		width: 95%;
		margin: 0 auto;

		.centerBoxtitle {
			font-size: 35rpx;
			color: #000000;
			font-weight: bold;
			margin: 20rpx 0;
		}

		.centerBoxDetail {
			color: #a5a5a5;
			font-size: 28rpx;
			letter-spacing: 2rpx;
			margin: 20rpx 0;
		}

		.top {
			margin: 70rpx 0;
		}
	}

	.bottomBox {
		position: fixed;
		width: 100%;
		bottom: 0;
		margin-bottom: 20rpx;
		z-index: 1000;
	}

	.buttonBox {
		width: 100%;
		margin: 0 auto;
		display: flex;
		justify-content: space-around;

		// margin-top: 200rpx;
	}

	.button_fix {
		width: 90%;
		height: 70rpx;
		// margin: 0 auto;
		color: #FFFFFF;
		background: #2749C8;
		font-weight: bold;
		letter-spacing: 5rpx;
		font-size: 28rpx;
		line-height: 70rpx;

	}
</style>